import { applyMiddleware, createStore } from 'redux'
import thunk from 'redux-thunk'
import reducer from './reducers'
import { composeWithDevTools } from 'redux-devtools-extension'
import { getToken } from '@/utils/storage'
// 优化
let middleware
if (process.env.NODE_ENV === 'development') {
  middleware = composeWithDevTools(applyMiddleware(thunk))
} else {
  middleware = applyMiddleware(thunk)
}
const store = createStore(
  reducer,
  {
    login: {
      token: getToken(),
    },
  },
  // composeWithDevTools(applyMiddleware(thunk))
  middleware
)
export default store
